<?php
/**
 * Created by PhpStorm.
 * User: Powerless
 * Date: 17/02/27
 * Time: 09:35
 */
Yaf_Loader::import(EXTEND_PATH.'/qmessage/Restapi.php');

Class Messages extends Restapi
{
    /**
     * 单发信息
     **/
    function send_msg($data_list)
    {
        list($account_id, $receiver, $text_content) = $data_list;

        $ret = $this->openim_send_msg($account_id, $receiver, $text_content);
        return $ret;
    }

    /**
     * 单发图片
     **/
    function send_msg_pic($data_list)
    {
        list($account_id, $receiver, $pic_path) = $data_list;

        $ret = $this->openim_send_msg_pic($account_id, $receiver, $pic_path);
        return $ret;
    }

    /**
     * 批量发信息
     **/
    function batch_sendmsg($data_list)
    {
        list($account_id_set, $text_content) = $data_list;
        $account_list = explode(",", $account_id_set);
        $ret = $this->openim_batch_sendmsg($account_list, $text_content);
        return $ret;
    }

    /**
     * 批量发图片
     **/
    function batch_sendmsg_pic($data_list)
    {
        list($account_id_set, $pic_path) = $data_list;
        $account_list = explode(",", $account_id_set);
        $ret = $this->openim_batch_sendmsg_pic($account_list, $pic_path);
        return $ret;
    }

    /**
     * 独立模式帐号同步
     **/
    function account_import($data_list)
    {
        list($identifier, $nick, $face_url) = $data_list;
        $ret = $this->openim_account_import($identifier,$nick,$face_url);
        return $ret;
    }

    /**
     * 托管模式存量帐号导入
     **/
    function register_account($data_list)
    {
        list($identifier, $identifier_type, $password) = $data_list;
        $ret = $this->openim_register_account($identifier, $identifier_type, $password);
        return $ret;
    }

    /**
     * 获取用户信息
     * account_list 为要拉取的用户id集合
     * tag_list 为选项字段，指明要拉取的信息，比如昵称
     **/
    function portrait_get($data_list)
    {
        list($account_id) = $data_list;
        $ret = $this->profile_portrait_get($account_id);
        return $ret;
    }

    /**
     * 设置用户信息
     **/
    function portrait_set($data_list)
    {
        list($account_id, $new_name) = $data_list;
        $ret = $this->profile_portrait_set($account_id, $new_name);
        return $ret;
    }

    /**
     * 建立好友关系
     **/
    function friend_import($data_list)
    {
        list($account_id, $receiver) = $data_list;
        $ret = $this->sns_friend_import($account_id, $receiver);
        return $ret;
    }

    /**
     * 解除好友关系
     **/
    function friend_delete($data_list)
    {
        list($account_id, $frd_id) = $data_list;
        $ret = $this->sns_friend_delete($account_id, $frd_id);
        return $ret;
    }

    /**
     * 解除用户所有好友关系
     **/
    function friend_delete_all($data_list)
    {
        list($account_id) = $data_list;
        $ret = $this->sns_friend_delete_all($account_id);
        return $ret;
    }

    /**
     * 校验好友关系
     **/
    function friend_check($data_list)
    {
        list($account_id, $to_account) = $data_list;
        $ret = $this->sns_friend_check($account_id, $to_account);
        return $ret;
    }

    /**
     * 获取用户全部好友
     **/
    function friend_get_all($data_list)
    {
        list($account_id) = $data_list;
        $ret = $this->sns_friend_get_all($account_id);
        return $ret;
    }

    /**
     * 获取用户指定好友
     **/
    function friend_get_list($data_list)
    {
        list($account_id, $frd_id) = $data_list;
        $ret = $this->sns_friend_get_list($account_id, $frd_id);
        return $ret;
    }

    /**
     * 获取app中所有群组(高级接口)a
     **/
    function get_appid_group_list($data_list)
    {

        $ret = $this->group_get_appid_group_list();
        return $ret;
    }

    /**
     * 创建群
     **/
    function create_group($data_list)
    {
        list($group_type, $group_name, $owner_id) = $data_list;
        $ret = $this->group_create_group($group_type, $group_name, $owner_id);
        return $ret;
    }

    /**
     * 转让群
     **/
    function change_group_owner($data_list)
    {
        list($group_type, $group_name, $owner_id) = $data_list;
        $ret = $this->group_change_group_owner($group_type, $group_name, $owner_id);
        return $ret;
    }

    /**
     * 获取群组详细信息
     **/
    function get_group_info($data_list)
    {
        list($group_id) = $data_list;
        $ret = $this->group_get_group_info($group_id);
        return $ret;
    }

    /**
     * 获取群组成员详细资料
     * limit, offset字段分别表示最大数量和偏移量
     **/
    function get_group_member_info($data_list)
    {
        list($group_id, $limit, $offset) = $data_list;
        $ret = $this->group_get_group_member_info($group_id, $limit, $offset);
        return $ret;
    }

    /**
     * 修改群组资料
     * 这里只修改群组名字
     **/
    function modify_group_base_info($data_list)
    {
        list($group_id, $group_name) = $data_list;

        $ret = $this->group_modify_group_base_info($group_id, $group_name);
        return $ret;
    }

    /*
     * 增加群组成员
     **/
    function add_group_member($data_list)
    {
        list($group_id, $member_id, $silence) = $data_list;

        $ret = $this->group_add_group_member($group_id, $member_id, $silence);
        return $ret;
    }

    /*
     * 删除群组成员
     * mem_list为增加用户列表，这里只有一个用户
     **/
    function delete_group_member($data_list)
    {
        list($group_id, $member_id, $silence) = $data_list;
        $ret = $this->group_delete_group_member($group_id, $member_id, $silence);
        return $ret;
    }

    /*
     * 修改群组成员身份
     **/
    function modify_group_member_info($data_list)
    {
        list($group_id, $account_id, $role) = $data_list;
        $ret = $this->group_modify_group_member_info($group_id, $account_id, $role);
        return $ret;
    }

    /*
     * 解散群组
     **/
    function destroy_group($data_list)
    {
        list($group_id) = $data_list;
        $ret = $this->group_destroy_group($group_id);
        return $ret;
    }

    /*
     * 获取某用户加入的群组
     **/
    function get_joined_group_list($data_list)
    {
        list($account_id) = $data_list;
        $ret = $this->group_get_joined_group_list($account_id);
        return $ret;
    }

    /*
     * 查询用户在某个群中身份
     **/
    function get_role_in_group($data_list)
    {
            list($group_id, $member_id) = $data_list;
            $ret = $this->group_get_role_in_group($group_id, $member_id);
        return $ret;
    }

    /*
     * 批量禁言/取消禁言
     **/
    function forbid_send_msg($data_list)
    {
        list($group_id, $member_id, $second) = $data_list;
        $ret = $this->group_forbid_send_msg($group_id, $member_id, $second);
        return $ret;
    }

    /**
     * 在某一群组里发普通消息
     **/
    function send_group_msg($data_list)
    {
        list($account_id, $group_id, $text_content) = $data_list;
        $ret = $this->group_send_group_msg($account_id, $group_id, $text_content);
        return $ret;
    }

    /**
     * 在某一群组里发送图片
     **/
    function send_group_msg_pic($data_list)
    {
        list($account_id, $group_id, $pic_path) = $data_list;
        $ret = $this->group_send_group_msg_pic($account_id, $group_id, $pic_path);
        return $ret;
    }

    /**
     * 在某一群组里发系统消息
     **/
    function send_group_system_notification($data_list)
    {
        list($group_id, $text_content, $receiver_id) = $data_list;
        //默认为空，发送全员
        $ret = $this->group_send_group_system_notification($group_id, $text_content, $receiver_id);
        return $ret;
    }

    /**
     * 导入群成员
     **/
    function import_group_member($data_list)
    {
        if($GLOBALS['argc'] == 5)
        {
            list($group_id, $member_id) = $data_list;
        }else{
            list($group_id, $member_id, $role) = $data_list;
        }
        $role = null;
        $ret = $this->group_import_group_member($group_id, $member_id, $role);
        return $ret;
    }

    /**
     * 导入群消息
     **/
    function import_group_msg($data_list)
    {
        list($group_id, $from_account, $text) = $data_list;

        $ret = $this->group_import_group_msg($group_id, $from_account, $text);
        return $ret;
    }

    /**
     * 导入群消息
     **/
    function set_unread_msg_num($data_list)
    {
        list($group_id, $member_account, $unread_msg_num) = $data_list;
        //默认为空，发送全员
        $ret = $this->group_set_unread_msg_num($group_id, $member_account, $unread_msg_num);
        return $ret;
    }
}